package liuliu.throughwaring.base;

import android.content.Context;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.os.StrictMode;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;

import net.tsz.afinal.FinalActivity;
import net.tsz.afinal.FinalDb;
import liuliu.custom.method.Utils;
import liuliu.custom.model.GlobalModel;
import liuliu.custom.model.HttpModel;
import liuliu.throughwaring.model.Key;

/**
 * BaseActivity声明相关通用方法
 * <p/>
 * Created by LiuWeiJie on 2015/7/22 0022.
 * Email:1031066280@qq.com
 */
public abstract class BaseActivity extends FinalActivity {
    public HttpModel httpModel;
    public FinalDb finalDb;
    public Utils mUtils;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        finalDb = FinalDb.create(this, false);
        httpModel = new HttpModel();
        initViews();
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
        mUtils = new Utils(this);

        initEvents();
    }

    public abstract void initViews();

    public abstract void initEvents();

    /**
     * 获取服务器信息
     */
    protected GlobalModel getGlobalModel() {
        GlobalModel model = new GlobalModel();
        {
            model.ServerName = mUtils.ReadString(Key.KEY_IP);
            model.ServerPort = mUtils.ReadString(Key.KEY_PORT);
        }
        return model;
    }

}
